package com.yunkaweilai.android.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import com.yunkaweilai.android.R;
import com.yunkaweilai.android.interfaces.DialogMemberPayInterface;
import com.yunkaweilai.android.utils.InputMethodUtils;
import com.yunkaweilai.android.view.MyToast;

import java.util.Timer;
import java.util.TimerTask;


/**
 * Created by Administrator on 2018/5/4.
 */

public class UpdateStoreNameDialog extends Dialog {
    private TextView idTvRight;
    private EditText idEdtTypeName;
    private Context context;
    private DialogMemberPayInterface myDialogInterface;


    public UpdateStoreNameDialog(@NonNull Context context,DialogMemberPayInterface dialogMemberPayInterface) {
        super(context, R.style.dialog);
        this.myDialogInterface = dialogMemberPayInterface;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_update_store_name);
        idTvRight = (TextView) findViewById(R.id.id_tv_right);
        idEdtTypeName = (EditText) findViewById(R.id.id_edt_type_name);
        idTvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InputMethodUtils.closeKey(getContext(), idEdtTypeName);
                if (idEdtTypeName.getText().toString().isEmpty()) {
                    MyToast.showShortToast(context, "未输入店铺名");
                } else {
                    myDialogInterface.passPay(idEdtTypeName.getText().toString());
                }
            }
        });
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                InputMethodManager inputManager = (InputMethodManager) idEdtTypeName.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(idEdtTypeName, 0);
            }
        }, 800);
    }


}
